package com.mcr.graduateprogram.controller;


import com.mcr.graduateprogram.bean.KeyOrder;
import com.mcr.graduateprogram.common.R;
import com.mcr.graduateprogram.service.IKeyOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author graduateprogram
 * @since 2023-02-25
 */
@Api(tags = "订单接口")
@CrossOrigin
@RestController
@RequestMapping("/graduateprogram/keyorder")
public class KeyOrderController {
    @Autowired
    private IKeyOrderService iOrderService;
    @ApiOperation(value = "下单操作")
    @PostMapping("createOrder")
    @CacheEvict(value = "graduationProgram",key = "'allGameSpaceification'")
    public R createOrder(@RequestBody KeyOrder keyOrder){
        return R.success(iOrderService.createOrder(keyOrder));
    }
    @ApiOperation(value = "分页查询订单")
    @GetMapping("selectByPage")
    public R selByPage(@RequestParam(value = "page")Integer page,
                       @RequestParam(value = "pageSize")Integer pageSize,
                       @RequestParam(value = "clienteleId",required = false)Long clienteleId){
        return R.success(iOrderService.selectByPage(page,pageSize,clienteleId));
    }
}
